var MY_EXCHANGE_STATISTICS_COM = (function() {
	
	/*列表取得*/
	function getHead(){
		e = '<tr>\
			<th width="20%" class="text-center">表名</th>\
			<th width="60%" class="text-center" id="tableThKey">主键</th>\
			<th width="20%" class="text-center">日期</th>\
		</tr>';

		return e;
	}
	
	/**
	 * 查看明细
	 * */
	function loadDetailItem(params,$thead,$tbody){
		$thead.empty();
		$thead.append(getHead);
		$tbody.empty();
		
		WeKnow.loading();
		if(params.type == 3){
			$("#tableThKey").html("插入数据");
		}
		
		$.ajax({ 
	        type: "POST", 
	        url: "invs_exchange_statistics.do/load_detail",
	        dataType: "json",
	        contentType:"application/json",
	        data: JSON.stringify(params),
	        async: true,//异步调用
	        success: function(data) {
	        	
	        	WeKnow.closeLoading();
	        	
				if (!WeKnow.filterAjaxResult(data)) return false; // session过期check
	        	
	        	if (data.errcode == 0) {
	        		// 把取到的结果放到
	        		var e = '';
	        		
	        		if ( 'datalist' in data && data.statisticsList.length == 0 ){
	        			e+='<tr class="danger">';
		    				e+='<td colspan=11 class="text-left">暂无数据</td>';
		    			e+='</tr>';
	        		} else {
	        			$(data.statisticsList).each(function( idx,_a){
    						e+='<tr';
	        				e+= '>';
                                // 表名
                                e+='<td class="text-center">'+ _a.tableName + '</td>';
								if(params.type == 3){
									// 数据统计数
									e+='<td class="text-center">'+ _a.dataCount + '</td>';
								}else{
									// 主键
									e+='<td class="text-center">'+ _a.primaryKey + '</td>';
								}
    							// 日期
		        				e+='<td class="text-center">'+ new Date(_a.createTime).format('yyyy-MM-dd hh:mm:ss') + '</td>';
    						e+='</tr>';
		        		});
	        		}
	        		$tbody.append(e);
	        		
	        	} else if (data.errcode == -1 ) {
	        		WeKnow.errorMsg( data.errMsg );
	        	} else {
	        		WeKnow.systemMsg('查询失败，请重新登录后再试');
	        	}
	        }
		});
	}
	
	return {
		loadDetailItem:loadDetailItem
	}
})();
